package GameObjects.Ships.Weapon.Bullets;

import GameObjects.GameObject;
import GameObjects.Instances.Instances;
import GameObjects.Physics.Position;
import GameObjects.Ships.Ship;
import GameObjects.Ships.Weapon.Weapon;
import Helper.HelperMethods;

public abstract class Bullet extends GameObject
{
	protected double damage;
	protected boolean toRemove = false;
	public double Damage(){return damage;}
	
	private double maxSpeed;
	private double rotateSpeed;
	
	public Bullet(Instances instances, Position position, double maxSpeed, double rotateSpeed, double damage) 
	{
		super(instances, position, 0, 0);
		this.damage = damage;
		this.maxSpeed = maxSpeed;
		this.rotateSpeed = rotateSpeed;
		// TODO Auto-generated constructor stub
	}
	
	@Override
	public boolean tick()
	{
		move();
		return HelperMethods.outOfBounds(position) || toRemove;
	}
	
	@Override
	public void move()
	{
		this.position.moveForward(maxSpeed);
	}
	
	@Override
	protected void collided(Ship other) 
	{
		
	}

	@Override
	protected void collided(Bullet other)
	{
		// TODO Auto-generated method stub
	}

	@Override
	protected void collided(Weapon other) 
	{
		
	}
	
	public void lowerDamage(double reduceDamageBy)
	{
		this.damage -= reduceDamageBy;
		if(this.damage < 0)
			this.damage = 0;
	}
	
	public void setToRemove()
	{
		this.toRemove = true;
	}
}
